package com.cet.qz.unit01.chapter1_1;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2020-12-16 22:18
 **/
public class Qz1_1_27 {

    public static int COUNT=0;

    public static double Binomial(int N,int k,double p){
        COUNT++;
        if(N==0 && k==0)
            return 1.0;
        if(N<0 || k<0)
            return 0.0;
        return p*Binomial(N-1,k-1,p) + (1-p)* Binomial(N-1,k,p);
    }

    public static void main(String[] args) {
        System.out.println(Binomial(1000,50,0.5)+" "+COUNT);
    }
}
